Skip to content

fix: resolve Memory Summary showing no data in Hardware Information (…#821

Open
amarnath-ac wants to merge 3 commits intomainfrom
mem_summary_no_data
Open

fix: resolve Memory Summary showing no data in Hardware Information (…#821
amarnath-ac wants to merge 3 commits intomainfrom
mem_summary_no_data

Conversation

@amarnath-ac
Copy link
Contributor

@amarnath-ac amarnath-ac commented Mar 4, 2026

#816)

Enhanced createMapInterfaceForHWInfo function to handle physical memory slice.
Added test for convertPhysicalMemorySlice function achieving 100% coverage.

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.76%. Comparing base (c133123) to head (8eb3095).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #821   +/-   ##
=======================================
  Coverage   39.76%   39.76%           
=======================================
  Files         114      114           
  Lines       10768    10768           
=======================================
  Hits         4282     4282           
  Misses       6087     6087           
  Partials      399      399           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amarnath-ac amarnath-ac requested a review from DevipriyaS17 March 4, 2026 06:24
@amarnath-ac amarnath-ac marked this pull request as ready for review March 4, 2026 08:35
@madhavilosetty-intel
Copy link
Contributor

@amarnath-ac Since we know the type of data which is []physical.PhysicalMemory, it's not necessary to use reflect. Reflect is generally used when the type is truly unknown at compile time. Instead, convert the typed slice to []interface{} at the source (in createMapInterfaceForHWInfo), which is consistent with how the other CIM types are handled. This way parseCIMResponse doesn't need to change at all.

internal\usecase\devices\wsman\message.go: line number 534

"responses": interfaceSlice(hwResults.PhysicalMemoryResult.Body.PullResponse.MemoryItems),

Add the following function to the same file

func interfaceSlice(items []physical.PhysicalMemory) []interface{} {
    result := make([]interface{}, len(items))
    for i, item := range items {
      result[i] = item
    }

	return result
}

I have tested this fix on AMT 19 and Memory Summary loads correctly. Please verify on your end as well.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the Hardware Information “Memory Summary shows no data” regression by making parseCIMResponse correctly handle responses values that come back as typed slices (e.g., []physical.PhysicalMemory) rather than only []interface{}.

Changes:

  • Update parseCIMResponse to convert typed slices in info["responses"] into []interface{} via reflection.
  • Add a focused private-unit test suite for parseCIMResponse, covering nil/invalid inputs and multiple responses/status shapes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/usecase/devices/info.go Converts typed-slice responses values to []interface{} so memory items populate correctly.
internal/usecase/devices/info_private_test.go Adds comprehensive unit tests for parseCIMResponse covering typed slice handling and edge cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@amarnath-ac
Copy link
Contributor Author

@amarnath-ac Since we know the type of data which is []physical.PhysicalMemory, it's not necessary to use reflect. Reflect is generally used when the type is truly unknown at compile time. Instead, convert the typed slice to []interface{} at the source (in createMapInterfaceForHWInfo), which is consistent with how the other CIM types are handled. This way parseCIMResponse doesn't need to change at all.

internal\usecase\devices\wsman\message.go: line number 534

"responses": interfaceSlice(hwResults.PhysicalMemoryResult.Body.PullResponse.MemoryItems),

Add the following function to the same file

func interfaceSlice(items []physical.PhysicalMemory) []interface{} {
    result := make([]interface{}, len(items))
    for i, item := range items {
      result[i] = item
    }

	return result
}

I have tested this fix on AMT 19 and Memory Summary loads correctly. Please verify on your end as well.

Thanks for feedback, will update as suggested.

@amarnath-ac
Copy link
Contributor Author

@amarnath-ac Since we know the type of data which is []physical.PhysicalMemory, it's not necessary to use reflect. Reflect is generally used when the type is truly unknown at compile time. Instead, convert the typed slice to []interface{} at the source (in createMapInterfaceForHWInfo), which is consistent with how the other CIM types are handled. This way parseCIMResponse doesn't need to change at all.
internal\usecase\devices\wsman\message.go: line number 534
"responses": interfaceSlice(hwResults.PhysicalMemoryResult.Body.PullResponse.MemoryItems),
Add the following function to the same file

func interfaceSlice(items []physical.PhysicalMemory) []interface{} {
    result := make([]interface{}, len(items))
    for i, item := range items {
      result[i] = item
    }

	return result
}

I have tested this fix on AMT 19 and Memory Summary loads correctly. Please verify on your end as well.

Thanks for feedback, will update as suggested.

@madhavilosetty-intel , Updated code

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…816)

Enhanced parseCIMResponse to handle typed slices using reflection.
Added test for parseCIMResponse function achieving 100% coverage.

Signed-off-by: C, Amarnath <amarnath.c@intel.com>
Signed-off-by: S, Devipriya <devipriya.s@intel.com>
Convert PhysicalMemory slice to interface slice at source.
@amarnath-ac amarnath-ac force-pushed the mem_summary_no_data branch from 3c0a659 to 8eb3095 Compare March 9, 2026 04:27
Address PR review feedback to use more specific function naming
that reflects its single-purpose for PhysicalMemory type conversion.
Copy link
Member

@rsdmike rsdmike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @amarnath-ac , generallly this is the simplicity we are looking for:
"responses": hwResults.PhysicalMemoryResult.Body.PullResponse.MemoryItems, , if its not useful from go-wsman-messages, then that is really where the change should be, can you take a look at fixing at the root of the problem instead of trying to convert something on top of the original conversion.

@amarnath-ac
Copy link
Contributor Author

Hey @amarnath-ac , generallly this is the simplicity we are looking for: "responses": hwResults.PhysicalMemoryResult.Body.PullResponse.MemoryItems, , if its not useful from go-wsman-messages, then that is really where the change should be, can you take a look at fixing at the root of the problem instead of trying to convert something on top of the original conversion.

Sure, I will analyze and fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants